<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      //请写一个函数，打印一个字符串中的第一个不重复的字符
      const str = 'jhdjkgjhjgy'
      function fn(str) {
        const map_str = {}

        for (let i = 0; i < str.length; i++) {
          if (map_str[str[i]]) {
            // console.log(map_str[str[i]]);
            map_str[str[i]] = map_str[str[i]] + 1
          } else {
            map_str[str[i]] = 1
          }
        }
        for (let j = 0; j < str.length; j++) {
          if (map_str[str[j]] === 1) {
            return str[j]
            // console.log(str[j])
          }
        }
      }
      console.log(fn(str))
    </script>
  </body>
</html>
